<template>
  <div class="audit-container">
    <el-form :model="formData" label-width="120px">
      <el-form-item label="当前审核人">
        <span>{{ currentAuditor }}</span>
      </el-form-item>
      <el-form-item label="审核结果">
        <el-radio-group v-model="auditResult">
          <el-radio label="同意">同意</el-radio>
          <el-radio label="拒绝">拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="拒绝原因" v-if="auditResult === '拒绝'">
        <el-select v-model="rejectReason" placeholder="请选择原因">
          <el-option label="原因1" value="原因1"></el-option>
          <el-option label="原因2" value="原因2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="补充说明">
        <el-input v-model="supplementaryExplanation" placeholder="请输入补充说明"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="toggleExplanationVisibility">显示/隐藏补充说明</el-button>
      </el-form-item>
      <el-form-item v-if="isExplanationVisible" label="详细补充说明">
        <el-input type="textarea" v-model="supplementaryExplanation" placeholder="请输入补充说明" :rows="5"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">确定</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentAuditor: '周审核',
      auditResult: '同意',
      rejectReason: '',
      supplementaryExplanation: '',
      isExplanationVisible: false
    };
  },
  methods: {
    toggleExplanationVisibility() {
      this.isExplanationVisible = !this.isExplanationVisible;
    },
    submit() {
      // 这里可以编写提交数据到后端的逻辑，例如使用 axios 发送请求
      console.log('提交审核：', {
        auditResult: this.auditResult,
        rejectReason: this.rejectReason,
        supplementaryExplanation: this.supplementaryExplanation
      });
    },
    cancel() {
      // 这里可以编写取消操作的逻辑，例如清空输入等
      this.auditResult = '同意';
      this.rejectReason = '';
      this.supplementaryExplanation = '';
      this.isExplanationVisible = false;
    }
  }
};
</script>

<style lang="scss" scoped>
.audit-container {
  padding: 20px;
  max-width: 600px;
  margin: 20px auto;
}
</style>
